home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 4 / QRZ Ham Radio Callsign Database - Volume 4.iso / files / tcpip / amiga / asrc29p.lha / ax25.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-29  |  6.6 KB  |  200 lines

  1. #ifndef    NULLAXR
  2.  
  3. #include "global.h"
  4.  
  5. /* AX.25 datagram (address) sub-layer definitions */
  6.  
  7. #define    NHASH        17    /* Number of hash chains in AX.25 routing
  8.                  * tables, LAPB control blocks and link
  9.                  * status tables
  10.                  */
  11. #define    MAXDIGIS    7    /* Maximum number of digipeaters */
  12. #define    ALEN        6    /* Number of chars in callsign field */
  13. #define    AXALEN        7    /* Total AX.25 address length, including SSID */
  14. #define    AXBUF        10    /* Buffer size for maximum-length ascii call */
  15.  
  16. /* Bits within SSID field of AX.25 address */
  17. #define    SSID        0x1e    /* Sub station ID */
  18. #define    REPEATED    0x80    /* Has-been-repeated bit in repeater field */
  19. #define    E        0x01    /* Address extension bit */
  20. #define    C        0x80    /* Command/response designation */
  21. /* Our AX.25 address */
  22. extern char Mycall[AXALEN];
  23.  
  24. /* AX.25 broadcast address: "QST   -0" in shifted ASCII */
  25. extern char Ax25_bdcst[AXALEN];
  26.  
  27. extern int Digipeat;
  28. extern int Ax25mbox;
  29.  
  30. /* Internal representation of an AX.25 header */
  31. struct ax25 {
  32.     char dest[AXALEN];        /* Destination address */
  33.     char source[AXALEN];        /* Source address */
  34.     char digis[MAXDIGIS][AXALEN];    /* Digi string */
  35.     int ndigis;            /* Number of digipeaters */
  36.     int nextdigi;            /* Index to next digi in chain */
  37.     int cmdrsp;            /* Command/response */
  38. };
  39.  
  40. /* C-bit stuff */
  41. #define    LAPB_UNKNOWN        0
  42. #define    LAPB_COMMAND        1
  43. #define    LAPB_RESPONSE        2
  44.  
  45. /* AX.25 routing table entry */
  46. struct ax_route {
  47.     struct ax_route *prev;        /* Linked list pointers */
  48.     struct ax_route *next;
  49.     char target[AXALEN];
  50.     char digis[MAXDIGIS][AXALEN];
  51.     int ndigis;
  52.     char type;
  53. #define    AX_LOCAL    1        /* Set by local ax25 route command */
  54. #define    AX_AUTO        2        /* Set by incoming packet */
  55.     char mode;
  56. #define    AX_DEFMODE    0        /* Use default interface mode */
  57. #define    AX_VC_MODE    1        /* Try to use Virtual Circuit */
  58. #define    AX_DATMODE    2        /* Try to use Datagrams Only  */
  59. };
  60. #define NULLAXR    ((struct ax_route *)0)
  61.  
  62. extern struct ax_route *Ax_routes[NHASH];
  63. extern struct ax_route Ax_default;
  64.  
  65. /* AX.25 Level 3 Protocol IDs (PIDs) */
  66. #define PID_X25        0x01    /* CCITT X.25 PLP */
  67. #define    PID_SEGMENT    0x08    /* Segmentation fragment */
  68. #define PID_TEXNET    0xc3    /* TEXNET datagram protocol */
  69. #define    PID_LQ        0xc4    /* Link quality protocol */
  70. #define    PID_APPLETALK    0xca    /* Appletalk */
  71. #define    PID_APPLEARP    0xcb    /* Appletalk ARP */
  72. #define    PID_IP        0xcc    /* ARPA Internet Protocol */
  73. #define    PID_ARP        0xcd    /* ARPA Address Resolution Protocol */
  74. #define    PID_NETROM    0xcf    /* NET/ROM */
  75. #define    PID_NO_L3    0xf0    /* No level 3 protocol */
  76.  
  77. #define    SEG_FIRST    0x80    /* First segment of a sequence */
  78. #define    SEG_REM        0x7f    /* Mask for # segments remaining */
  79.  
  80. #define    AX_EOL        "\r"    /* AX.25 end-of-line convention */
  81.  
  82. /* Link quality report packet header, internal format */
  83. struct lqhdr {
  84.     int16 version;        /* Version number of protocol */
  85. #define    LINKVERS    1
  86.     int32    ip_addr;    /* Sending station's IP address */
  87. };
  88. #define    LQHDR    6
  89. /* Link quality entry, internal format */
  90. struct lqentry {
  91.     char addr[AXALEN];    /* Address of heard station */
  92.     int32 count;        /* Count of packets heard from that station */
  93. };
  94. #define    LQENTRY    11
  95.  
  96. /* Link quality database record format
  97.  * Currently used only by AX.25 interfaces
  98.  */
  99. struct lq {
  100.     struct lq *next;
  101.     char addr[AXALEN];    /* Hardware address of station heard */
  102.     struct iface *iface;    /* Interface address was heard on */
  103.     int32 time;        /* Time station was last heard */
  104.     int32 currxcnt;    /* Current # of packets heard from this station */
  105.     int32 disc;
  106.     int32 dm;
  107.     int32 frmr;
  108.     int32 i;
  109.     int32 rej;
  110.     int32 rnr;
  111.     int32 rr;
  112.     int32 sabm;
  113.     int32 ua;
  114.     int32 ui;
  115.     int32 invalid;
  116. };
  117. #define    NULLLQ    (struct lq *)0
  118.  
  119. extern struct lq *Lq;    /* Link quality record headers */
  120.  
  121. /* Structure used to keep track of monitored destination addresses */
  122. struct ld {
  123.     struct ld *next;    /* Linked list pointers */
  124.     char addr[AXALEN];/* Hardware address of destination overheard */
  125.     struct iface *iface;    /* Interface address was heard on */
  126.     int32 time;        /* Time station was last mentioned */
  127.     int32 currxcnt;    /* Current # of packets destined to this station */
  128. };
  129. #define    NULLLD    (struct ld *)0
  130.  
  131. extern struct ld *Ld;    /* Destination address record headers */
  132.  
  133. /* Codes for the open_ax25 call */
  134. #define    AX_PASSIVE    0
  135. #define    AX_ACTIVE    1
  136. #define    AX_SERVER    2    /* Passive, clone on opening */
  137.  
  138. #define    AXHEARD_PASS    0    /* Log both src and dest callsigns */
  139. #define    AXHEARD_NOSRC    1    /* do not log source callsign */
  140. #define    AXHEARD_NODST    2    /* do not log destination callsign */
  141. #define    AXHEARD_NONE    3    /* do not log any callsign */
  142.  
  143. /* In ax25.c: */
  144. struct ax_route *ax_add __ARGS((char *,int,char digis[][AXALEN],int));
  145. int ax_drop __ARGS((char *));
  146. struct ax_route *ax_lookup __ARGS((char *));
  147. void ax_recv __ARGS((struct iface *,struct mbuf *));
  148. int ax_send __ARGS((struct mbuf *bp,struct iface *iface,int32 gateway,int prec,
  149.     int del,int tput,int rel));
  150. int ax_output __ARGS((struct iface *iface,char *dest,char *source,int16 pid,
  151.     struct mbuf *data));
  152. void axarp __ARGS((void));
  153. int sendframe __ARGS((struct ax25_cb *axp,int cmdrsp,int ctl,struct mbuf *data));
  154.  
  155. /* In ax25cmd.c: */
  156. void st_ax25 __ARGS((struct ax25_cb *axp));
  157.  
  158. /* In axhdr.c: */
  159. struct mbuf *htonax25 __ARGS((struct ax25 *hdr,struct mbuf *data));
  160. int ntohax25 __ARGS((struct ax25 *hdr,struct mbuf **bpp));
  161.  
  162. /* In axlink.c: */
  163. void getlqentry __ARGS((struct lqentry *ep,struct mbuf **bpp));
  164. void getlqhdr __ARGS((struct lqhdr *hp,struct mbuf **bpp));
  165. void logsrc __ARGS((struct iface *iface,char *addr,char control));
  166. void logdest __ARGS((struct iface *iface,char *addr));
  167. char *putlqentry __ARGS((char *cp,char *addr,int32 count));
  168. char *putlqhdr __ARGS((char *cp,int16 version,int32 ip_addr));
  169.  
  170. /* In ax25user.c: */
  171. int ax25val __ARGS((struct ax25_cb *axp));
  172. int disc_ax25 __ARGS((struct ax25_cb *axp));
  173. int kick_ax25 __ARGS((struct ax25_cb *axp));
  174. struct ax25_cb *open_ax25 __ARGS((struct iface *,char *,char *,
  175.     int,int16,
  176.     void (*) __ARGS((struct ax25_cb *,int)),
  177.     void (*) __ARGS((struct ax25_cb *,int)),
  178.     void (*) __ARGS((struct ax25_cb *,int,int)),
  179.     int user));
  180. struct mbuf *recv_ax25 __ARGS((struct ax25_cb *axp,int16 cnt));
  181. int reset_ax25 __ARGS((struct ax25_cb *axp));
  182. int send_ax25 __ARGS((struct ax25_cb *axp,struct mbuf *bp,int pid));
  183.  
  184. /* In ax25subr.c: */
  185. int addreq __ARGS((char *a,char *b));
  186. int16 ax25hash __ARGS((char *s));
  187. struct ax25_cb *cr_ax25 __ARGS((char *addr));
  188. void del_ax25 __ARGS((struct ax25_cb *axp));
  189. struct ax25_cb *find_ax25 __ARGS((char *));
  190. char *pax25 __ARGS((char *e,char *addr));
  191. int setcall __ARGS((char *out,char *call));
  192.  
  193. /* In socket.c: */
  194. void beac_input __ARGS((struct iface *iface,char *src,struct mbuf *bp));
  195. void s_arcall __ARGS((struct ax25_cb *axp,int cnt));
  196. void s_ascall __ARGS((struct ax25_cb *axp,int old,int new));
  197. void s_atcall __ARGS((struct ax25_cb *axp,int cnt));
  198.  
  199. #endif    /* NULLAXADDR */
  200.